package com.leo.controller;

import com.leo.base.exception.result.R;
import com.leo.bean.Student;
import com.leo.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ExceptionTestController
 * @Description
 * @Author wangss
 * @date 2020.09.16 21:50
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class ExceptionTestController {

    @Autowired
    private IStudentService studentService;

    /**
     * 这里的返回可以前后协商返回数据类型，并不一定是R
     *
     * @return
     */
    @RequestMapping("/list")
    public R list() {
        List<Student> students = studentService.queryStudent();
        return R.ok().data("item", students).message("用户列表");
    }

    @RequestMapping("/global")
    public R global(int number) {
        int i = 20 / number;
        return R.ok();
    }

    @RequestMapping("/list1")
    public List<Student> list1() {
        List<Student> students = studentService.queryStudent();
        return students;
    }
}
